﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Utils;

public partial class MasterBackEnd : System.Web.UI.MasterPage
{
    private int m_permission;

    public int Permission
    {
        get { return m_permission; }
        set { m_permission = value; }
    }
    protected void Page_Init(object sender, EventArgs e)
    {        

        if (!AdminUtils.IsLogin)
        {
            Response.Redirect("/login");
        }
        else
        {
            string strFunction;

            strFunction = Request.Url.AbsolutePath.Substring(Request.Url.AbsolutePath.IndexOf("/") + 1).ToLower();
            if (strFunction == "index.htm" || string.IsNullOrWhiteSpace(strFunction))
            {
                m_permission = 1;
            }
            else
            {
                if (strFunction == "admininfo" || strFunction == "changepass")
                    m_permission = 15;
                else
                    m_permission = CtrAdmin.GetPermission(strFunction);
            }
            
            if ((m_permission & 1) != 1)
            {
                Response.Redirect("/accessdenied");
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
}
